<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 收件箱</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <!-- 引入公共css -->
	<#include "/inc/header.ftl"/>

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="row">
        <div class="page-title-box">
            <p class="page-title">
                模板管理
            </p>
        </div>

        <div class="col-sm-3">
            <div class="ibox float-e-margins back-white">
                <div class="ibox-content mailbox-content">
                    <div class="file-manager">
                        <h2 class="text-center">模板分类</h2>

                        <ul class="folder-list m-b-md" style="padding: 0">
                            <#if groupDtoList?? && groupDtoList?size gt 0>
                            <#list groupDtoList as item>
                            <li class="group-li-js <#if item_index = 0> back-select</#if>" id="${item.id!''}">
                                <a href="javascript:void(0)"> <i class="fa fa-folder-open-o"></i> ${item.name!''} </a>
                            </li>
                            </#list>
                            </#if>
                        </ul>
                        <div class="clearfix"></div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-9 animated fadeInRight">
            <div class="mail-box-header">
                <h3 class="text-center">
                    模板列表
                </h3>
                <div class="mail-tools tooltip-demo m-t-md">
                    <a class="btn btn-success btn-sm" id="toCreateTemp" href="javascript:void(0)" data-toggle="tooltip" data-placement="left" title="新增模板">新增模板</a>
                    <button class="btn btn-success btn-sm" id="delPath" data-toggle="tooltip" data-placement="top" title="删除模板"><i class="fa fa-trash-o"></i>
                    </button>

                </div>
            </div>
            <div class="mail-box">
                <div id="tableList"></div>
            </div>
        </div>
    </div>
</div>

<!-- 引入公共js -->
<#include "/inc/footer.ftl"/>


<script>
    $(document).ready(function () {
        var groupId = $(".group-li-js").eq(0).attr("id");
        getTemplate(groupId);

        $(".group-li-js").click(function () {
            $(".group-li-js").removeClass("back-select");
            $(this).addClass("back-select");
            var id = $(this).attr("id");
            groupId = id;
            getTemplate(id);
        });
        
        $("#toCreateTemp").click(function(){
        	location.href = "/auto/code/template/create?groupId=" + groupId;
        });
        
        $("#delPath").click(function () {
        debugger
            var selectIds = checkbox.getCheckedboxIds("#tableList");
            $.ajax({
                url : '/auto/code/template/del',
                type : 'POST',
                data : {
                    idList : selectIds
                },
                success : function(data) {
                    window.location.href = "/auto/code/template/list";
                },
                error : function(result) {
                    parent.layer.alert("发生错误！");
                }
            });
        });
    });
    
    
    function getTemplate(groupId) {
        var paramJson = {
            groupId : groupId,
            pageSize : 20,
            pageNum : 1
        };
        //查询groupId 模板分类对应的模板
        $("#tableList").pagination({
            url : "/auto/code/template/list",
            paramJson : paramJson,
            callback:function(){
            }
        });
    }

</script>

</body>

</html>
